﻿using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenFaq.Core;
using OpenFaq.Core.UserModule;

namespace OpenFaq.Application.AcceptanceTests
{
	[TestClass]
	public class AssemblyFixture
	{
		[AssemblyInitialize]
		public static void AssemblyInitialize(TestContext context)
		{
			//OpenFaqContext.DropCreateDatabaseAlways();

			CreateTestData();
		}

		private static void CreateTestData()
		{
			//Regirst single user by default
			var membershipProvider = new CustomMembershipProvider();
			membershipProvider.Initialize(string.Empty, new NameValueCollection());

			using (var db = new OpenFaqContext())
			{
				//Regist user if doesn't already exist
				User user = db.Users.FirstOrDefault(usr => usr.Username == "acceptance_test_user1");
				if (user == null)
				{
					MembershipCreateStatus status;
					membershipProvider.CreateUser("acceptance_test_user1", "password_1", "acceptance_test_user1@test1.com", null, null, true, null,
											  out status);
				}
			}

		}

		[AssemblyCleanup]
		public static void AssemblyCleanup()
		{
		
		}
	}
}
